Package gwtappcontainer.testhelpers

Source Code of gwtappcontainer.testhelpers.MockGateKeeper

package gwtappcontainer.testhelpers;

import gwtappcontainer.server.apis.admin.GateKeeper;
import gwtappcontainer.server.apis.admin.Roles.Role;
import gwtappcontainer.shared.apis.admin.RoleProp;
import gwtappcontainer.shared.apis.admin.UserProp;

import java.util.ArrayList;
import java.util.HashMap;

import com.google.appengine.api.users.User;

public class MockGateKeeper extends GateKeeper {
 
  HashMap<String, UserProp> userProps = new HashMap<String, UserProp>();
   
  public void allowRoleToUser(String email, Role role) {
    email = email.toLowerCase();
   
    RoleProp roleProp = new RoleProp();
    roleProp.name = role.toString()
   
    UserProp userProp;
    if (userProps.containsKey(email)) {
      userProp = userProps.get(email);           
    } else {
      userProp = new UserProp();
      userProp.roles = new ArrayList<RoleProp>();
      userProp.email = email;             
      userProps.put(email, userProp);
    }
   
    userProp.roles.add(roleProp);
  }   
     
  @Override
  protected UserProp getUserProp(User user) {         
    UserProp prop = userProps.get(user.getEmail().toLowerCase());           
    return prop;
  }
}
TOP

Related Classes of gwtappcontainer.testhelpers.MockGateKeeper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.